package com.letoken.platform.repo.mall.dao;

import com.letoken.platform.repo.app.res.mall.MallDayRecodeRes;
import com.letoken.platform.repo.mall.po.AppMallDayStatistics;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 店铺日统计数据 Mapper 接口
 * </p>
 *
 * @author author
 * @since 2023-07-18
 */
public interface AppMallDayStatisticsMapper extends BaseMapper<AppMallDayStatistics> {


    @Select("select turnover,order_num,access_num,contribut,date from app_mall_day_statistics where mall_id = #{mallId} and date >= #{startTime} and date < #{endTime} ")
    List<MallDayRecodeRes> getDataByMonth(@Param("mallId") Integer mallId , @Param("startTime") String startTime, @Param("endTime")String endTime);




    @Select("select sum(turnover) as turnover, sum(order_num) as order_num ,sum(access_num) as access_num, sum(contribut) as contribut from app_mall_day_statistics where mall_id = #{mallId}")
    AppMallDayStatistics statisticsTotal(@Param("mallId") Integer mallId);


    @Select("select id from app_mall_day_statistics where mall_id = #{mallId} and date= #{date}")
    Integer recordIsExits(@Param("mallId") Integer mallId, @Param("date")LocalDate date);

    @Select("select sum(access_num) from app_mall_day_statistics where mall_id = #{mallId} ")
    Integer totalAccessNum(@Param("mallId") Integer mallId);


}
